Finally, we need to think about setting and placing the nine movie symbols to predetermined sizes and positions, based on the lengths of the edges of the cells established in the previous step. The movie clip placement and the instance name are as shown in the earlier figure. For the sake of convenience, the whole of the matrix comprising the nine cells is set as a movie symbol with the instance name tenkey (the standard Japanese term for the numeric keypad), and the movie symbols key 1 to key 9 of the different cells are placed in the lower layer.
First, letΓÇÖs look at setting the cellsΓÇÖ sizes, which involves nothing more complicated than setting PX1 to 3 for the vertical edges and PY1 to 3 for the horizontal edges. The next piece of script designates, in sequence, percentages for the sizes of cells grouped by row as follows: key 1 to key 3, key 4 to key 6, and key 7 to key 9. These are the default values for the cell sizes, with the initial setting at frame 1 being a constant designated as 60.
i =1
while (i<=3) {
setProperty (ΓÇ£/tenkey/keyΓÇ¥ add i, _xscale, eval(ΓÇ£PXΓÇ¥ add i)*100/L);
setProperty (ΓÇ£/tenkey/keyΓÇ¥ add i, _yscale PY1*100/L);
If you have more matrices, youΓÇÖll have to build a more elegant multiple loop, but, since weΓÇÖre looking at three rows and three columns, I have used this rather less elegant but easy to understand script.
Next, weΓÇÖll look at placing the cell in the desired position. For this, we need to achieve a seamless line up, in accordance with the sizes of the cells, from the bottom-left position of the matrix, in sequence vertically and horizontally. First of all, the term for the initial setting of frame 1 is:
drawX1 =getProperty (ΓÇ£/tenkey/key1ΓÇ¥, _x);
drawY1 =getProperty (ΓÇ£/tenkey/key1ΓÇ¥, _y);
The bottom left co-ordinates,drawX1, drawY1, are designated as constants. Next, the placement is done in accordance with the sizes of the cells. This is how it looks when converted into script: